//
//  FriendsListController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/17.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "FriendsListController.h"
#import "AskQuestionsSuccessfulVC.h"

@interface FriendsListController ()
/**<#属性#>*/
@property (nonatomic,strong)PubulicNavSerachView*titleView;

/**推荐按钮*/
@property (nonatomic,strong)UIButton*fansBtn;
/**好友按钮*/
@property (nonatomic,strong)UIButton*attentionBtn;

/**推荐底部线条*/
@property (nonatomic,strong)UIView*fanLine;
/**好友底部线条*/
@property (nonatomic,strong)UIView*attenLine;
/**listViewTool*/
@property (nonatomic,strong)UITableViewTool*listViewTool;
/**数据源*/
@property (nonatomic,strong)NSMutableArray*dataSoure;

@end

@implementation FriendsListController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.titleView = self.titleView;
    [self createUI];
    self.isShowLiftBack = NO;
}
-(void)createUI{
    UIView * view = [self createSwichtView];
    
    UIView * line = UIView.new;
    line.backgroundColor = UIColorFromRGB(0xF5F7F5);

    [self.view addSubview:view];
    [self.view addSubview:line];
    
    [self.listViewTool.listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(0);
        make.top.mas_equalTo(view.mas_bottom);
    }];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(40);
    }];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(8);
        make.top.mas_equalTo(view.mas_bottom);
    }];

}
#pragma mark --懒加载
-(UIView *)createSwichtView{
    UIView * view = [[UIView alloc] initWithFrame:CGRectZero];
    view.userInteractionEnabled = YES;
    
    self.fanLine = [UIView new];
    self.fanLine.backgroundColor = UIColorFromRGB(0x009966);
    
    self.attenLine = [UIView new];
    self.attenLine.backgroundColor = UIColorFromRGB(0x009966);
    
    [view addSubview:self.fansBtn];
    [view addSubview:self.attentionBtn];
    [view addSubview:self.fanLine];
    [view addSubview:self.attenLine];
    
    self.fanLine.hidden = !self.fansBtn.selected;
    self.attenLine.hidden = !self.attentionBtn.selected;
    
    [self.fansBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(90);
        make.centerY.mas_equalTo(0);
    }];
    [self.fanLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.fansBtn);
        make.height.mas_equalTo(3);
        make.width.mas_equalTo(20);
        make.top.mas_equalTo(self.fansBtn.mas_bottom).offset(1);
    }];
    
    [self.attentionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-90);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(self.fansBtn.mas_right).offset(116);
    }];
    
    [self.attenLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.attentionBtn);
        make.height.mas_equalTo(3);
        make.width.mas_equalTo(20);
        make.top.mas_equalTo(self.attentionBtn.mas_bottom).offset(1);
    }];
    
    
    return view;
}
-(UIButton*)fansBtn{
    if(!_fansBtn){
        _fansBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_fansBtn setTitle:@"推荐" forState:UIControlStateNormal];
        [_fansBtn setTitleColor:UIColorFromRGB(0x009966) forState:UIControlStateSelected];
        [_fansBtn setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
        _fansBtn.selected = YES;
        kWeakSelf(weakSelf);
        [_fansBtn addActionHandler:^{
            weakSelf.fansBtn.selected = YES;
            weakSelf.fanLine.hidden = NO;
            
            weakSelf.attentionBtn.selected = NO;
            weakSelf.attenLine.hidden = YES;
        }];
    }
    return _fansBtn;
}
-(UIButton*)attentionBtn{
    if(!_attentionBtn){
        _attentionBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_attentionBtn setTitle:@"好友" forState:UIControlStateNormal];
        [_attentionBtn setTitleColor:UIColorFromRGB(0x009966) forState:UIControlStateSelected];
        [_attentionBtn setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
        _attentionBtn.selected = NO;
        kWeakSelf(weakSelf);
        [_attentionBtn addActionHandler:^{
            weakSelf.fansBtn.selected = NO;
            weakSelf.fanLine.hidden = YES;
            
            weakSelf.attentionBtn.selected = YES;
            weakSelf.attenLine.hidden = NO;
        }];
        
    }
    return _attentionBtn;
}

-(PubulicNavSerachView*)titleView{
    if(!_titleView){
        _titleView=[[PubulicNavSerachView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 35)];
        kWeakSelf(weakSelf);
        [_titleView.backBtn addActionHandler:^{
            [weakSelf backBtnClicked];
        }];
    }
    return _titleView;
}
-(UITableViewTool*)listViewTool{
    if(!_listViewTool){
        _listViewTool=[[UITableViewTool alloc] initWithFrame:CGRectZero style:UITableViewStylePlain registerCellClassName:NSStringFromClass([AskQuestionsSuccessCell class]) identifier:NSStringFromClass([AskQuestionsSuccessCell class]) dataArray:self.dataSoure delegate:self dataSourceBlock:^(id  _Nonnull TempCell, NSIndexPath * _Nonnull indexPath, id  _Nonnull TempData) {
            
        } selectCell:^(id  _Nonnull TempCell, NSIndexPath * _Nonnull indexPath, id  _Nonnull TempData) {
            
        }];
                
    }
    return _listViewTool;
}
-(NSMutableArray *)dataSoure{
    if (!_dataSoure) {
        
        _dataSoure =[[NSMutableArray alloc] initWithObjects:@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"", nil];
    }
    return _dataSoure;
}

@end
